package main.scala.exec

import java.io.File

import com.typesafe.config.{Config, ConfigFactory}
import main.scala.utils.ZkUtil

object ItemcenterStop {

  def stop(config: Config): Unit = {
    if (config.getBoolean("System.canStop") && config.getString("System.canStopType")=="zookeeper"){
      val stopFlag: String = config.getString("System.stopMark")
      val children = System.currentTimeMillis().toString
      val zkUtil = new ZkUtil(config.getString("dependencies.zookeeper.servers"))
      zkUtil.createNode(stopFlag,children)
    }
  }

  def main(args: Array[String]): Unit = {
    if(args.length != 1){
      println("请输入执行程序的配置文件路径")
      sys.exit(1)
    }
    stop(ConfigFactory.parseFile(new File(args(0))))
  }
}
